#include "file_utils.h"

#include <filesystem>
#include <iostream>


namespace fs = std::filesystem;

bool FileUtils::IsFile(const std::string & filepath)
{
    if (!IsExist(filepath)) {
        return false;
    }

    std::error_code ec;
    bool res = fs::is_regular_file(filepath, ec);
    if (ec) {
        std::cerr << "Error occurs when checking file " << filepath << ". Reson: " << ec.message() << std::endl;
    }
    return res;
}

bool FileUtils::IsExist(const std::string &filepath)
{
    bool res = fs::exists(filepath);
    return res;
}

size_t FileUtils::FileSize(const std::string &filepath)
{
    uintmax_t size = fs::file_size(filepath);
    return  static_cast<size_t>(size);
}
